package cn.edu.hziee;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "SubmitServlet",urlPatterns = "/SubmitServlet")
public class SubmitServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String number = request.getParameter("Number");
        String name = request.getParameter("Name");
        String chinese = request.getParameter("Chinese");
        String math = request.getParameter("Math");
        String english = request.getParameter("English");
        HttpSession session = request.getSession();
        Grade grade = new Grade();
        List<Grade> card = (List) session.getAttribute("card");
        int id = (int) session.getAttribute("id");
        grade = card.get(id);
        grade.setNumber(number);
        grade.setName(name);
        grade.setChinese(chinese);
        grade.setMath(math);
        grade.setEnglish(english);
        card.set(id,grade);
        session.setAttribute("card",card);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
